/*
 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved.
 */

#ifndef BURNDLGHSAN_H
#define BURNDLGHSAN_H

#include <QMainWindow>
#include "BurnDlg.h"
#include "IPConfigSetting.h"
#include "ui_BurnDlgHsan.h"
#include "EraseConfigSetting.h"

namespace BurnDlg {

class BurnDlgHsan : public BurnDlg {
    Q_OBJECT
public:
    explicit BurnDlgHsan(ChipType chipType, QWidget *pParent = nullptr);
    ~BurnDlgHsan() override;
    void InitConnectSignal();

public slots:
    void SlotCbnSetfocusComboCom() const;
    void SlotGetIpAddressList();
    void SlotBtnClickIPConfig(bool checked);
    void SlotSaveAddress(QString address, QString subnetMask, QString gateway);
    void SlotBnClickedButtonSelectfile() override;
    void SlotBnClickedButtonStartburn() override;
    void SlotInsertPlainText(const QString &editStr) override;
    void SlotBurnFileFailed();
    void SlotBurnFileFinish();
    void SlotEmptyFlashStateChanged(int state);
    void SlotBtnClickEraseConfig(bool checked) const;
    void SlotSetEraseConfig(unsigned int cbEraseConfig,
        const QVector<EraseConfig> &vecEraseConfig) const;
    void SlotCurrentIndexChangedType(const QString &str);
    void SlotVidPidTextEdited(const QString &str) const;
    void SlotCreateNewFwpkgFile();
    void SlotSaveSpiltFwpkgFile();

private:
    void HandleWhenUiTtnStartIsStart();
    bool SetUiCbTypeItem(Ui::BurnDlgHsan* uiNeedSet) const;
    void AnalyseBinFile(QString filePath);
    void InitTableView() const;
    void AnalyseBinFileSub(QMap<int, BIN_INFO> &mapBinInfo, QMap<int, bool> &mapCheck,
                           QMap<int, BIN_INFO> &mapLastBinInfo, QMap<int, bool> &mapLastBinCheck) const;
    void InitBurnCtrl() override;
    bool ConfigComPort() override;
    bool WhetherProssRunning(const QString &processName) const;
    void InitMenus();
    void contextMenuEvent(QContextMenuEvent *event) override;

private:
     Ui::BurnDlgHsan *ui;
     IPConfigSetting *ipConfigSetting;
     QMap<QString, IPInfo> mapIPInfo;
     QAction *actChangeChip;
     QAction *actAbout;
     bool isEmptyFlash;
     EraseConfigSetting *eraseConfigSetting;
     QMenu *tableViewMenu;
};

}
#endif // BURNDLGHSAN_H
